/**
 * Created by zhang on 2016/1/29.
 */
var gulp = require('gulp'),
    minifyCSS = require('gulp-minify-css'),
    sass = require('gulp-sass'),
    uglify = require('gulp-uglify'),
    rename = require('gulp-rename'),
    concat = require('gulp-concat')
    //imagemin = require('gulp-imagemin')
//压缩图片
/*gulp.task('imagemin',function(){
    gulp.src('./backend/web/pic/font/!*')
        .pipe(imagemin())
        .pipe(gulp.dest('./backend/web/pic/min/'))
});*/
//储存css
gulp.task('css', function () {
    gulp.src('./backend/web/ass/**/*.css')
        .pipe(minifyCSS())
        .pipe(gulp.dest('./backend/web/_build/'))
    // .pipe(rename({ suffix: '.min' }))
    // .pipe(minifyCSS())
    // .pipe(gulp.dest('./_build/min/'))
});
//压缩js
gulp.task('script', function() {
    gulp.src('./backend/web/ass/**/*.js')
        .pipe(uglify())
        .pipe(gulp.dest('./backend/web/_build/'))
})
//编译scss
gulp.task('sass', function() {
    gulp.src('./backend/web/ass/**/*.scss')
        .pipe(sass())
        .pipe(gulp.dest('./backend/web/ass/'));
});

gulp.task('default', function(){
    gulp.run('sass', 'css', 'script');
    gulp.watch(['./backend/web/ass/**/*.scss','./backend/web/ass/**/*.js'], function(){
        gulp.run('sass','css', 'script');
    });
});